# -*- coding:utf-8 -*-
from collections import deque

# 双端队列
# 操作复杂度 O(V+E) 即人数（顶点数）+边数

graph = {"you": ["alice", "bob", "claire_m"], "bob": ["anuj", "peggy"], "anuj": ["anuj"], "alice": ["aaa"]}


def person_is_seller(person):
    return person[-1] == 'm'


def search(name):
    search_queue = deque()
    search_queue += graph[name]

    searched = []
    while search_queue:
        person = search_queue.popleft()
        if person not in searched:
            if person_is_seller(person):
                print(person + ' is a mango seller')
                return True
            else:
                search_queue += graph[person]
                searched.append(person)
    return False


print(search('you'))
